//
//  HQNameSettingViewController.m
//  MobileiOS
//
//  Created by 郝庆松 on 2018/5/28.
//  Copyright © 2018年 PCITC. All rights reserved.
//

#import "HQNameSettingViewController.h"

@interface HQNameSettingViewController ()

@end

@implementation HQNameSettingViewController

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    //写入这个方法后,这个页面将没有这种效果
    [IQKeyboardManager sharedManager].enable = NO;
    //点击背景收回键盘
    [IQKeyboardManager sharedManager].shouldResignOnTouchOutside = YES;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [_inputItem becomeFirstResponder];
    _inputItem.text = self.inputText;
    if([self.pushType isEqualToString:@"shop"]){
        self.title = @"设置经营单位名称";
        _inputItem.placeholder = @"请输入经营单位名称";
    }else if([self.pushType isEqualToString:@"name"]){
        self.title = @"设置联系人名称";
        _inputItem.placeholder = @"请输入联系人名称";
    }else if([self.pushType isEqualToString:@"phone"]){
        self.title = @"设置手机号";
        _inputItem.placeholder = @"请输入手机号码";
    }else if([self.pushType isEqualToString:@"productIntroduce"]){
        self.title = @"设置主要产品介绍";
        _inputItem.placeholder = @"请输入主要产品介绍";
    }
    self.navigationItem.rightBarButtonItem = [UIBarButtonItem barButtonItemTitle:@"确定" withTitleColor:[self colorHexValue:0x98A4B3] withFont:15 withTarget:self withSelector:@selector(contentEdit)];
}

/**
 确认修改
 */
-(void)contentEdit{
    if([self isInputEmpty:_inputItem.text]){
        if([self.pushType isEqualToString:@"shop"]){
            [self tostView:@"请输入店名"];
        }else if([self.pushType isEqualToString:@"name"]){
            [self tostView:@"请输入称呼"];
        }else if([self.pushType isEqualToString:@"phone"]){
            [self tostView:@"请输入手机号码"];
        }else if([self.pushType isEqualToString:@"productIntroduce"]){
            [self tostView:@"请输入主要产品介绍"];
        }
        return;
    }
    if([self.delegate respondsToSelector:@selector(reloadType:withText:)]){
        [self.delegate reloadType:self.pushType withText:_inputItem.text];
        [self.navigationController popViewControllerAnimated:YES];
    }
}

- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    //最后还设置回来,不要影响其他页面的效果
    [IQKeyboardManager sharedManager].enable = YES;
    //点击背景收回键盘
    [IQKeyboardManager sharedManager].shouldResignOnTouchOutside = NO;
}

@end
